import com.spring.demo.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.env.PropertySource;

public class App {
    public static void main(String[] args) {
        //1.得到 spring
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.从 Spring 容器中获取到 Bean 对象
       // Student student = (Student) context.getBean("student");// 根据名称获取

        //Student student = context.getBean(Student.class); //根据类型获取

        Student student = context.getBean("student",Student.class); //通过名称+类型查询对象
        Student stu = context.getBean("stu",Student.class);
        System.out.println("student == stu ->" + (student == stu));
        //3.使用 Bean(非必须)
        student.sayHi();
    }
}
